package cn.meibang.common.beauty.provider.dao;

import cn.apestar.core.database.BaseMapper;
import cn.meibang.common.beauty.provider.domain.BeautyConsultationOrderUserAnswerExtra;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface BeautyConsultationOrderUserAnswerExtraMapper extends BaseMapper {
    @Delete({
            "delete from beauty_consultation_order_user_answer_extra",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into beauty_consultation_order_user_answer_extra (id, tag, ",
            "user_id, openid, order_id, question_id, ",
            "extra_answer_id, extra_answer_content, ",
            "create_by, create_date, ",
            "update_by, update_date, ",
            "remarks, del_flag, institution_id)",
            "values (#{id,jdbcType=BIGINT}, #{tag,jdbcType=VARCHAR}, ",
            "#{userId,jdbcType=BIGINT}, #{openid}, #{orderId,jdbcType=BIGINT}, #{questionId,jdbcType=BIGINT}, ",
            "#{extraAnswerId,jdbcType=BIGINT}, #{extraAnswerContent,jdbcType=VARCHAR}, ",
            "#{createBy,jdbcType=BIGINT}, #{createDate,jdbcType=TIMESTAMP}, ",
            "#{updateBy,jdbcType=BIGINT}, #{updateDate,jdbcType=TIMESTAMP}, ",
            "#{remarks,jdbcType=VARCHAR}, #{delFlag,jdbcType=CHAR}, #{institutionId,jdbcType=BIGINT})"
    })
    int insert(BeautyConsultationOrderUserAnswerExtra record);

    @InsertProvider(type = BeautyConsultationOrderUserAnswerExtraSqlProvider.class, method = "insertSelective")
    int insertSelective(BeautyConsultationOrderUserAnswerExtra record);

    @Select({
            "select",
            "id, tag, user_id, openid, order_id, question_id, extra_answer_id, extra_answer_content, ",
            "create_by, create_date, update_by, update_date, remarks, del_flag, institution_id",
            "from beauty_consultation_order_user_answer_extra",
            "where id = #{id,jdbcType=BIGINT} and del_flag = '1'"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "tag", property = "tag", jdbcType = JdbcType.VARCHAR),
            @Result(column = "user_id", property = "userId", jdbcType = JdbcType.BIGINT),
            @Result(column = "openid", property = "openid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "order_id", property = "orderId", jdbcType = JdbcType.BIGINT),
            @Result(column = "question_id", property = "questionId", jdbcType = JdbcType.BIGINT),
            @Result(column = "extra_answer_id", property = "extraAnswerId", jdbcType = JdbcType.BIGINT),
            @Result(column = "extra_answer_content", property = "extraAnswerContent", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
            @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.CHAR),
            @Result(column = "institution_id", property = "institutionId", jdbcType = JdbcType.BIGINT)
    })
    BeautyConsultationOrderUserAnswerExtra selectByPrimaryKey(Long id);

    @Select({
            "select",
            "id, tag, user_id, openid, order_id, question_id, extra_answer_id, extra_answer_content, ",
            "create_by, create_date, update_by, update_date, remarks, del_flag, institution_id",
            "from beauty_consultation_order_user_answer_extra",
            "where tag = #{tag} and del_flag = '1'"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "tag", property = "tag", jdbcType = JdbcType.VARCHAR),
            @Result(column = "user_id", property = "userId", jdbcType = JdbcType.BIGINT),
            @Result(column = "openid", property = "openid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "order_id", property = "orderId", jdbcType = JdbcType.BIGINT),
            @Result(column = "question_id", property = "questionId", jdbcType = JdbcType.BIGINT),
            @Result(column = "extra_answer_id", property = "extraAnswerId", jdbcType = JdbcType.BIGINT),
            @Result(column = "extra_answer_content", property = "extraAnswerContent", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
            @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.CHAR),
            @Result(column = "institution_id", property = "institutionId", jdbcType = JdbcType.BIGINT)
    })
    List<BeautyConsultationOrderUserAnswerExtra> selectByTag(@Param("tag") String tag);

    @UpdateProvider(type = BeautyConsultationOrderUserAnswerExtraSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(BeautyConsultationOrderUserAnswerExtra record);

    @Update({
            "update beauty_consultation_order_user_answer_extra",
            "set tag = #{tag,jdbcType=VARCHAR},",
            "user_id = #{userId,jdbcType=BIGINT},",
            "openid = #{openid,jdbcType=VARCHAR},",
            "order_id = #{orderId,jdbcType=BIGINT},",
            "question_id = #{questionId,jdbcType=BIGINT},",
            "extra_answer_id = #{extraAnswerId,jdbcType=BIGINT},",
            "extra_answer_content = #{extraAnswerContent,jdbcType=VARCHAR},",
            "create_by = #{createBy,jdbcType=BIGINT},",
            "create_date = #{createDate,jdbcType=TIMESTAMP},",
            "update_by = #{updateBy,jdbcType=BIGINT},",
            "update_date = #{updateDate,jdbcType=TIMESTAMP},",
            "remarks = #{remarks,jdbcType=VARCHAR},",
            "del_flag = #{delFlag,jdbcType=CHAR},",
            "institution_id = #{institutionId,jdbcType=BIGINT}",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BeautyConsultationOrderUserAnswerExtra record);
}